package com.zwan.oam_rtc.utils.messages;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;


/*(SDSMsgHead) + 请求消息结构*/
public class SLPMessage extends AbstractStruct {
    private SDSMsgHead msgHead = new SDSMsgHead();
    private byte[] body = new byte[0];
    private int eventid;

    public SLPMessage(){
    	super();
    }

	public void readFromBuffer(ByteBuffer bf) {
    	msgHead.readFromBuffer(bf);
    	if (bf.position() < bf.limit()){
    		body = new byte[bf.limit() - bf.position()];
    		bf.get(body);
    	}
	}

	public void writeToBuffer(ByteBuffer bf) {
		msgHead.writeToBuffer(bf);
        bf.put(body);
	}
	

    public int getLength() {
        return msgHead.getLength() + body.length;
    }

    //get set
    public byte[] getBody() {
        return body;
    }
    
    public int getBodyLen(){
    	return body.length;
    }

    public void setBody(byte[] body) {
        if (body != null) {
            this.body = body;
        }
    }

    public void setBody(MsgStruct msg, ByteOrder byteOrder){
        this.setBody(msg.getByteArray(byteOrder));
    }
    
    public SDSMsgHead getMsgHead() {
        return msgHead;
    }

    public void setMsgHead(SDSMsgHead msgHead) {
        if (msgHead != null) {
            this.msgHead = msgHead;
        }
    }

    public int getEventid() {
        return eventid;
    }

    public void setEventid(int eventid) {
        this.eventid = eventid;
    }

	
}
